using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.Logging.ASPMVC.Entity;
using T2.Logging.ASPMVC.Entity.Interface;
using T2.Logging.Business.Entities.Interfaces;
using T2.Logging.Business.Entities;
using T2.Logging.ASPMVC.Entity.Translators;

//--Change Management Control - Application ASPMVC Entity Translator  --**********************
//--Created By: James Rooks
//--Description: Application Translator
//--Created Date: 02/15/2013 20:34:18
//--*************************************************************
namespace T2.Logging.ASPMVC.Entity.Translators
{
	public class ApplicationUITranslator 
	{
		public IApplication_biz TranslateToBusinessLayer(IApplication_ui _translateFrom)
        {
            IApplication_biz temp = new Application_biz();
		
			if(_translateFrom != null)
			{
			    temp.Action = _translateFrom.Action;
                temp.Caller = _translateFrom.Caller;
                temp.Role = _translateFrom.Role;
                temp.PageSize = _translateFrom.PageSize;
                temp.PageNumber = _translateFrom.PageNumber;
                temp.SortColumn = _translateFrom.SortColumn;
                temp.SortType = _translateFrom.SortType;
                temp.TotalRows = _translateFrom.TotalRows;
			if (_translateFrom.ApplicationID != null)
			{
				temp.ApplicationID = _translateFrom.ApplicationID;
			}
			else
			{
			temp.ApplicationID = -1;
			}
			if (_translateFrom.ApplicationName != null)
			{
				temp.ApplicationName = _translateFrom.ApplicationName;
			}
			else
			{
			temp.ApplicationName = String.Empty;
			}
			if (_translateFrom.TS != null)
			{
				temp.TS = TranslatorHelper.TranslateTimeStampToBusiness(_translateFrom.TS);
			}
			if (_translateFrom.CreatedBy != null)
			{
				temp.CreatedBy = _translateFrom.CreatedBy;
			}
			else
			{
			temp.CreatedBy = String.Empty;
			}
			if (_translateFrom.CreatedDt != null)
			{
				temp.CreatedDt = _translateFrom.CreatedDt;
			}
			else
			{
			temp.CreatedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.ModifiedBy != null)
			{
				temp.ModifiedBy = _translateFrom.ModifiedBy;
			}
			else
			{
			temp.ModifiedBy = String.Empty;
			}
			if (_translateFrom.ModifiedDt != null)
			{
				temp.ModifiedDt = _translateFrom.ModifiedDt;
			}
			else
			{
			temp.ModifiedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.TenantID != null)
			{
				temp.TenantID = _translateFrom.TenantID;
			}
			else
			{
			temp.TenantID = -1;
			}
			TenantUITranslator TenantUITranslator = new TenantUITranslator();
			temp.Tenant =TenantUITranslator.TranslateToBusinessLayer(_translateFrom.Tenant);
			
			
			}
			return temp;
			
		}
		
		public IApplication_ui TranslateFromBusinessLayer(IApplication_biz _translateFrom)
        {
            IApplication_ui temp = new Application_ui();
		
			if(_translateFrom != null)
			{
			    temp.Action = _translateFrom.Action;
                temp.Caller = _translateFrom.Caller;
                temp.Role = _translateFrom.Role;
                temp.PageSize = _translateFrom.PageSize;
                temp.PageNumber = _translateFrom.PageNumber;
                temp.SortColumn = _translateFrom.SortColumn;
                temp.SortType = _translateFrom.SortType;
                temp.TotalRows = _translateFrom.TotalRows;
			if (_translateFrom.ApplicationID != null)
			{
				temp.ApplicationID = _translateFrom.ApplicationID;
			}
			else
			{
			temp.ApplicationID = -1;
			}
			if (_translateFrom.ApplicationName != null)
			{
				temp.ApplicationName = _translateFrom.ApplicationName;
			}
			else
			{
			temp.ApplicationName = String.Empty;
			}
			if (_translateFrom.TS != null)
			{
				temp.TS = TranslatorHelper.TranslateTimeStampFromBusiness(_translateFrom.TS);
			}
			if (_translateFrom.CreatedBy != null)
			{
				temp.CreatedBy = _translateFrom.CreatedBy;
			}
			else
			{
			temp.CreatedBy = String.Empty;
			}
			if (_translateFrom.CreatedDt != null)
			{
				temp.CreatedDt = _translateFrom.CreatedDt;
			}
			else
			{
			temp.CreatedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.ModifiedBy != null)
			{
				temp.ModifiedBy = _translateFrom.ModifiedBy;
			}
			else
			{
			temp.ModifiedBy = String.Empty;
			}
			if (_translateFrom.ModifiedDt != null)
			{
				temp.ModifiedDt = _translateFrom.ModifiedDt;
			}
			else
			{
			temp.ModifiedDt = Convert.ToDateTime(@"01\01\1753");
			}
			if (_translateFrom.TenantID != null)
			{
				temp.TenantID = _translateFrom.TenantID;
			}
			else
			{
			temp.TenantID = -1;
			}
			TenantUITranslator TenantUITranslator = new TenantUITranslator();
			temp.Tenant =TenantUITranslator.TranslateFromBusinessLayer(_translateFrom.Tenant);
			
			
			}
			return temp;
			
		}
	
	
	}


}